package com.zhouheng.springbootmultithreading.tuling.hashMap.threadpool;

import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;

public class Task implements Runnable {
    private String name;

    public Task(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    AtomicInteger atomicInteger = new AtomicInteger();

    @Override
    public void run() {
        /**
         * 测试run方法中抛出异常，会中断周期任务，异常还会被上级吃掉
         */
//        atomicInteger.incrementAndGet();
//        if (true) {
//            throw new NullPointerException();
//        }
        System.out.println("Executing : " + name + ", Current Seconds : " + new Date().getSeconds());
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}